using UnityEngine;

public interface IState
{
    void IEnter();
    void IExit();
    void ILogicUpdate();
    void IPhysicUpdate();
}

public abstract class StateMachine : MonoBehaviour
{
    public IState _currentState;

    void Update()
    {
        _currentState.ILogicUpdate();
    }

    void FixedUpdate()
    {
        _currentState.IPhysicUpdate();
    }

    public void SwitchOn(IState state)
    {
        _currentState = state;
        _currentState.IEnter();
    }

    public void SwitchState(IState newState)
    {
        _currentState.IExit();
        SwitchOn(newState);
    }
}
